<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络编程基础教程</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            display: inline-block;
        }
        
        .network-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .concept-card {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border-radius: 12px;
            padding: 20px;
            margin: 15px 0;
            border-left: 4px solid #667eea;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 8px;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <div class="network-icon inline-block mb-6">
                <i class="fas fa-network-wired text-6xl"></i>
            </div>
            <h1 class="text-5xl font-bold mb-4">网络编程基础教程</h1>
            <p class="text-xl opacity-90 max-w-2xl mx-auto">
                深入理解计算机网络原理，掌握Java网络编程核心技术
            </p>
            <div class="mt-8 flex justify-center space-x-4">
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-layer-group mr-2"></i>OSI七层模型
                </span>
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-exchange-alt mr-2"></i>TCP/IP协议
                </span>
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-code mr-2"></i>Socket编程
                </span>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- 什么是网络 -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-globe-asia mr-3 text-purple-600"></i>什么是网络？
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="concept-card">
                    <h3 class="text-xl font-semibold mb-3">
                        <i class="fas fa-sitemap mr-2 text-purple-600"></i>网络概念
                    </h3>
                    <p class="text-gray-700">
                        <span class="drop-cap">网</span>络是由点和线构成的系统，表示诸多对象间的相互联系。在计算机领域，网络让信息能够在不同设备间自由流动。
                    </p>
                </div>
                
                <div class="concept-card">
                    <h3 class="text-xl font-semibold mb-3">
                        <i class="fas fa-desktop mr-2 text-purple-600"></i>计算机网络
                    </h3>
                    <p class="text-gray-700">
                        为实现资源共享和信息传递，通过通信线路连接起来的若干主机（Host）。让分散的计算资源能够协同工作。
                    </p>
                </div>
            </div>

            <div class="bg-gray-50 rounded-lg p-6">
                <h4 class="text-lg font-semibold mb-4 text-gray-800">
                    <i class="fas fa-network-wired mr-2"></i>常见计算机网络类型
                </h4>
                <div class="grid md:grid-cols-3 gap-4">
                    <div class="bg-white p-4 rounded-lg shadow-sm hover:shadow-md transition-shadow">
                        <div class="text-purple-600 text-2xl mb-2">
                            <i class="fas fa-globe"></i>
                        </div>
                        <h5 class="font-semibold mb-1">互联网（Internet）</h5>
                        <p class="text-sm text-gray-600">点与点相连的全球性网络</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm hover:shadow-md transition-shadow">
                        <div class="text-purple-600 text-2xl mb-2">
                            <i class="fas fa-spider"></i>
                        </div>
                        <h5 class="font-semibold mb-1">万维网（WWW）</h5>
                        <p class="text-sm text-gray-600">端与端相连的信息系统</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm hover:shadow-md transition-shadow">
                        <div class="text-purple-600 text-2xl mb-2">
                            <i class="fas fa-microchip"></i>
                        </div>
                        <h5 class="font-semibold mb-1">物联网（IoT）</h5>
                        <p class="text-sm text-gray-600">物与物相连的智能网络</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 网络模型 -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-layer-group mr-3 text-purple-600"></i>网络模型
            </h2>

            <div class="grid md:grid-cols-2 gap-8">
                <!-- OSI模型 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800">OSI参考模型</h3>
                    <p class="text-gray-600 mb-4">开放式系统互联，ISO组织在1985年研究的网络互联模型</p>
                    
                    <div class="space-y-2">
                        <div class="bg-gradient-to-r from-purple-500 to-purple-600 text-white p-3 rounded-lg">
                            <i class="fas fa-user mr-2"></i>应用层 - HTTP、FTP、SMTP
                        </div>
                        <div class="bg-gradient-to-r from-purple-600 to-purple-700 text-white p-3 rounded-lg">
                            <i class="fas fa-file-code mr-2"></i>表示层 - 数据格式转换、加密
                        </div>
                        <div class="bg-gradient-to-r from-purple-700 to-purple-800 text-white p-3 rounded-lg">
                            <i class="fas fa-handshake mr-2"></i>会话层 - 建立和维持会话
                        </div>
                        <div class="bg-gradient-to-r from-purple-800 to-purple-900 text-white p-3 rounded-lg">
                            <i class="fas fa-exchange-alt mr-2"></i>传输层 - TCP、UDP协议
                        </div>
                        <div class="bg-gradient-to-r from-indigo-700 to-indigo-800 text-white p-3 rounded-lg">
                            <i class="fas fa-route mr-2"></i>网络层 - IP地址分配
                        </div>
                        <div class="bg-gradient-to-r from-indigo-800 to-indigo-900 text-white p-3 rounded-lg">
                            <i class="fas fa-link mr-2"></i>数据链路层 - MAC地址
                        </div>
                        <div class="bg-gradient-to-r from-gray-700 to-gray-800 text-white p-3 rounded-lg">
                            <i class="fas fa-ethernet mr-2"></i>物理层 - 物理介质传输
                        </div>
                    </div>
                </div>

                <!-- TCP/IP模型 -->
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-800">TCP/IP模型</h3>
                    <p class="text-gray-600 mb-4">因特网使用的参考模型，基于TCP和IP协议</p>
                    
                    <div class="space-y-3">
                        <div class="bg-gradient-to-r from-blue-500 to-blue-600 text-white p-4 rounded-lg">
                            <i class="fas fa-window-maximize mr-2"></i>
                            <span class="font-semibold">应用层</span>
                            <p class="text-sm mt-1">传送最终形态的数据，HTTP、FTP等</p>
                        </div>
                        <div class="bg-gradient-to-r from-blue-600 to-blue-700 text-white p-4 rounded-lg">
                            <i class="fas fa-truck mr-2"></i>
                            <span class="font-semibold">传输层</span>
                            <p class="text-sm mt-1">传送文本数据，TCP、UDP协议</p>
                        </div>
                        <div class="bg-gradient-to-r from-blue-700 to-blue-800 text-white p-4 rounded-lg">
                            <i class="fas fa-map-marked-alt mr-2"></i>
                            <span class="font-semibold">网络层</span>
                            <p class="text-sm mt-1">分配地址和传送二进制数据，IP协议</p>
                        </div>
                        <div class="bg-gradient-to-r from-blue-800 to-blue-900 text-white p-4 rounded-lg">
                            <i class="fas fa-plug mr-2"></i>
                            <span class="font-semibold">接口层</span>
                            <p class="text-sm mt-1">建立电路连接，以太网、ADSL等</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 网络模型对比图 -->
            <div class="mt-8 bg-gray-50 rounded-lg p-6">
                <h4 class="text-lg font-semibold mb-4 text-center">网络模型架构对比</h4>
                <div class="mermaid">
                    graph LR
                        subgraph OSI七层模型
                            A1[应用层]
                            A2[表示层]
                            A3[会话层]
                            A4[传输层]
                            A5[网络层]
                            A6[数据链路层]
                            A7[物理层]
                            A1 --> A2 --> A3 --> A4 --> A5 --> A6 --> A7
                        end
                        
                        subgraph TCP/IP四层模型
                            B1[应用层]
                            B2[传输层]
                            B3[网络层]
                            B4[接口层]
                            B1 --> B2 --> B3 --> B4
                        end
                        
                        A1 -.-> B1
                        A2 -.-> B1
                        A3 -.-> B1
                        A4 -.-> B2
                        A5 -.-> B3
                        A6 -.-> B4
                        A7 -.-> B4
                </div>
            </div>
        </div>

        <!-- 网络编程三要素 -->